<?php
require('modelo_twitter.php');

if($_POST)
{
	if($_POST['tipo']=='menciones')
	{
		$results=buscar_menciones($_POST['palabras']);
//		echo '<pre>'.print_r($results, true).'</pre>';
	}
	else if($_POST['tipo']=='hash')
	{
		$results=buscar_hash($_POST['palabras']);
	}
	else if($_POST['tipo']=='palabra')
	{
		$results=buscar_palabra($_POST['palabras']);
	}
	?>
	<form id="form" name="form" method="post" style="text-align:left;">
	<input type="hidden" id="palabras" name="palabras" value="<?=$_POST['palabras']?>">

	<?php
	for($a=0;$a<count($results);$a++)
	{
	?>
	<input type="hidden" id="usuario_<?=$a?>" name="usuario_<?=$a?>" value="<?=$results[$a]->from_user?>">
	<input type="hidden" id="mensaje_<?=$a?>" name="mensaje_<?=$a?>" value="<?=$results[$a]->text?>">
    <table width="70%" style="text-align:left;">
    <tr><td rowspan="3"  width="50px" align="center"><input type="checkbox" id="pati_<?=$a?>" name="pati_<?=$a?>"><label><b>Ticket</b></label></td>
    <td rowspan="3"  width="70px" align="center"><input type="checkbox" id="valor_<?=$a?>" name="valor_<?=$a?>"><label><b>Campaña</b></label></td>
    <td rowspan="3" width="40px"><img src="<?php echo $results[$a]->profile_image_url; ?>" border="0" width="40px" height="40px"></td>
	<td style="color:blue;font-family: Helvetica;font-size: 14px; font-weight:bold;"><?php echo $results[$a]->from_user;?></td></tr>
    <tr><td style="font-family: Helvetica;font-size: 13px;"><?php echo $results[$a]->text;?></td></tr>
    <tr><td style="font-family: Helvetica;font-size: 13px;"><?php echo $results[$a]->created_at;?><br><br><br></td></tr>
    </table>
<?php //$r2 = $connection->post('statuses/update', array('status'=>'@'.$r1[$a]['user']['screen_name'].' '.'probando replay'));
 }

	
}

if($_GET)
{
	if($_GET['tipo']=='menciones')
	{
		$results=buscar_menciones($_GET['palabras']);
//		echo '<pre>'.print_r($results, true).'</pre>';
	}
	else if($_GET['tipo']=='hash')
	{
		$results=buscar_hash($_GET['palabras']);
	}
	else if($_GET['tipo']=='palabra')
	{
		$results=buscar_palabra($_GET['palabras']);
	}
	?>
	<form id="form" name="form" method="post" style="text-align:left;">
	<input type="hidden" id="palabras" name="palabras" value="<?=$_GET['palabras']?>">

	<?php
	for($a=0;$a<count($results);$a++)
	{
	?>
	<input type="hidden" id="usuario_<?=$a?>" name="usuario_<?=$a?>" value="<?=$results[$a]->from_user?>">
	<input type="hidden" id="mensaje_<?=$a?>" name="mensaje_<?=$a?>" value="<?=$results[$a]->text?>">
    <table width="70%" style="text-align:left;">
    <tr><td rowspan="3"  width="50px" align="center"><input type="checkbox" id="pati_<?=$a?>" name="pati_<?=$a?>"><label><b>Ticket</b></label></td>
    <td rowspan="3"  width="70px" align="center"><input type="checkbox" id="valor_<?=$a?>" name="valor_<?=$a?>"><label><b>Campaña</b></label></td>
    <td rowspan="3" width="40px"><img src="<?php echo $results[$a]->profile_image_url; ?>" border="0" width="40px" height="40px"></td>
	<td style="color:blue;font-family: Helvetica;font-size: 14px; font-weight:bold;"><?php echo $results[$a]->from_user;?></td></tr>
    <tr><td style="font-family: Helvetica;font-size: 13px;"><?php echo $results[$a]->text;?></td></tr>
    <tr><td style="font-family: Helvetica;font-size: 13px;"><?php echo $results[$a]->created_at;?><br><br><br></td></tr>
    </table>
<?php //$r2 = $connection->post('statuses/update', array('status'=>'@'.$r1[$a]['user']['screen_name'].' '.'probando replay'));
 }

	
}
?>



<input type='hidden' name='tuits' value='<?=$a?>' id='tuits'>

<input type='hidden' name='representante' value='0' id='representante'>
<input type='hidden' name='categoria' value='0' id='categoria'>
</form>
<?php

	$link=mysql_connect("localhost","root","");
	mysql_select_db("demo_inventario");
	$query="SELECT * FROM empresa";
	$consulta=mysql_query($query);
	
	$select="<form id='ayudita' name='ayudita' method='post'>Selecciona Empresa:<br><select id='sel' name='sel' onchange=\"reprea();\">
	<option value='0'>Selecciona</option>";
	
	while($row=mysql_fetch_array($consulta))
	{
		$select.="<option value='".$row['id_empresa']."'>".$row['nombre']."</option>";
	}
	$select.="</select></form>";

echo "<div id='total' style='text-align:center; width:100%;'>
   	 	
   	 	<div id='uno' style='text-align:center'>".$select."<br></div>
   	 	<div id='dos' style='text-align:center'></div>
   	 	<div id='tres' style='text-align:center'></div>
   	 	<div id='errorsito' style='text-align:center;  color:red;'></div>
   	 
   	 <div id='individual' style='text-align:center;'>
   	 
   	 <form method='post'  action='javascript:verificando();'>
   	 	
		<input type='submit' value='Agregar nueva campaña'>		
	</form>
   	 </div>
   	 
   	 
   	 </div>";
   	 
   	 /*echo "<div id='individual' style='text-align:center; width:100%;'>
   	 
   	 <form method='post'  action='javascript:formus(document.getElementById(\"form\"),\"buscatuit/addUser.php\",\"mmm\");'>
   	 	
		<input type='submit' value='Agregar nueva campaña'>		
	</form>
   	 </div><br><br>";*/

?>